	
	//동호회정보
	function clsSelfClub_Info(){
		this.listData = null;	
		this._HTMLDom = null;
		this._init();
	}
	
	clsSelfClub_Info.prototype = {
		
		_init: function(){
			var $layer = $("section#self_club>section article.club_info");
			var $title = $("section#self_club>header>div.top_title_B");
			this._HTMLDom = {
				"$layer": $layer	
				, "$title": $title
			}
		}
		, setData: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $title = this._HTMLDom["$title"];
			
			if(!this.listData) return;
			
			$title.find("h2").html(this.listData["동호회명"]);
			
			$layer.find("span.img img").attr("src", _util.getDefaultClubImage(this.listData["로고이미지"]));
			$layer.find("ul li:eq(0)").html("<em>매니저</em>"+ this.listData["클럽장"]["닉네임"]);
			$layer.find("ul li:eq(1)").html("<em>분류</em>"+ this.listData["카테고리"]["카테고리명"]);
			
			if(_util.getLogin()){
				$layer.find("ul li:eq(2) span").hide().eq(this.listData["가입여부"]).show();	
			}else {
				$layer.find("ul li:eq(2) span").hide().eq(0).show().html("로그인을 해주십시요.");
			}
			
			
			if(this.listData["가입여부"]){
				//alert("미가입");
				$layer.find("p.bt").hide().eq(this.listData["내상태"]).show();							
			}else {
				//alert("가입");
				if(this.listData["내상태"]){
					//alert("관리자회원");
					$layer.find("p.bt").hide().eq(this.listData["내상태"]).show();				
				}else {
					//alert("일반회원");
					$layer.find("p.bt").hide();						
				}
			}
			
			$layer.find("ul li:eq(3)").html("<em>회원수</em>"+ this.listData["가입자수"] + "명");
			$layer.find("div.c_txt").html(this.listData["동호회소개"]);			
		}
		, $getBtnAdmin: function(){
			return this._HTMLDom["$layer"].find("p.bt:eq(1)");
		}			
		, $getBtnJoin: function(){
			return this._HTMLDom["$layer"].find("p.bt:eq(0)");
		}
		, $getBtnClose: function(){
			return this._HTMLDom["$title"].find("div.top_right a");	
		}	
	}
	
	//라운드
	function clsSelfClub_Round(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsSelfClub_Round.prototype = {
		_init: function(){
			var $layer = $("section#self_club>section div.club_home_board:eq(0) ul");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("li:eq(1)")
				, "$resultCnt": $("section#self_club>section div.s_result mark:eq(0)")
				, "$empty": $layer.find("li:eq(0)")
			}			
			$layer.empty();
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			
			this._HTMLDom["$resultCnt"].html("("+ this.listData.length +")");
			
			for(var i=0;i<this.listData.length;++i){
				$layer.append($element.clone(true));	
			}
		
			$layer.find("li").each(function(n){				
				$(this).find("div").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim());
				}).after(thisClass.listData[n]["라운드명"]).remove();
				
				if(thisClass.listData[n]["라운딩진행상태"]=="P"){
					$(this).find("div span.state_ing").attr("class", "state_ing").html("진행");
				}else if(thisClass.listData[n]["라운딩진행상태"]=="C"){
					$(this).find("div span.state_ing").attr("class", "state_ok").html("확정");
				}else if(thisClass.listData[n]["라운딩진행상태"]=="D"){
					$(this).find("div span.state_ing").attr("class", "state_ing").html("마감");
				}
			});
			
			if(!this.listData.length) {				
				$layer.append(this._HTMLDom["$empty"]);
			}
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	//공지사항
	function clsSelfClub_Notice(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsSelfClub_Notice.prototype = {
		_init: function(){
			var $layer = $("section#self_club>section div.club_home_board:eq(1) ul");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("li:eq(1)")
				, "$resultCnt": $("section#self_club>section div.s_result mark:eq(1)")
				, "$empty": $layer.find("li.no_list")
			}				
			$layer.empty();
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;			
			
			$layer.empty();
			
			if(!this.listData.length) {				
				$layer.append(this._HTMLDom["$empty"]);
			}
			
			this._HTMLDom["$resultCnt"].html("("+ this.listData.length +")");
			
			for(var i=0;i<this.listData.length;++i){
				$layer.append($element.clone(true));	
			}
			
			$layer.find("li").each(function(n){
				$(this).find("a div").html(thisClass.listData[n]["제목"]);
				$(this).find("a time").html(_util.fDateYmd(thisClass.listData[n]["작성일"]) + "&nbsp;" + _util.fTime(thisClass.listData[n]["작성시간"]));
			});
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	//데이터연동		
	function clsComm_SelfClub(){
		this.clubScheduleList = null;
		this.clubScheduleListRequest = null;
		this.clubNoticeList = null;		
		this.clubNoticeListRequest = null;
		this._init();
	}	
	clsComm_SelfClub.prototype = {
		_init: function(){
			this.clubScheduleListRequest = {
				 "동호회키":null
				, "라운드키": null
				, "페이지": null				
			}
			
			this.clubNoticeListRequest = {
				 "동호회키":null		
			}
		}
//------------------------ 라운드목록------------------------//		
		, getClubScheduleList: function(){
			var thisClass = this;
			var club_seq = this.clubScheduleListRequest["동호회키"];
			var szPage = this.clubScheduleListRequest["페이지"];
			var szClosedRoundDispYn = "N";
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename", "getClubRoundList");   
        	objJson.putPub("listcount", 10);
        	objJson.putPub("currpageno", szPage);
        	
			objJson.putParameter("clubSeq", club_seq);      
			objJson.putParameter("closedRoundDispYn", szClosedRoundDispYn);      
			
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		thisClass.clubScheduleList = [];
        		
        		var items = ret["msp"]["contents"]["items"];
        		
        		if(items){					
				
					if(!items.length){
						items = new Array(items);
					}
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						//동호회목록
						thisClass.clubScheduleList.push({
							"동호회키": _util.nvl(obj["roundInfo"]["clubSeq"])
							, "아이디": _util.nvl(obj["userMaster"]["userId"])
							, "닉네임": _util.nvl(obj["userMaster"]["nickname"])
							, "라운드키": _util.nvl(obj["roundInfo"]["roundSeq"])
							, "라운드일자": _util.nvl(obj["roundInfo"]["reservDate"])
							, "라운드요일": _util.nvl(obj["roundInfo"]["reservDay"])
							, "라운드시간": _util.nvl(obj["roundInfo"]["firstTime"])
							, "코스명": _util.nvl(obj["roundInfo"]["golfclubCourseInfo"])
							, "홀수": _util.nvl(obj["roundInfo"]["holeInfo"])
							, "라운드명": _util.nvl(obj["roundInfo"]["title"])
							, "모집팀수": _util.nvl(obj["roundInfo"]["totalTeamCnt"])
							, "모집인원수": _util.nvl(obj["roundInfo"]["totalMember"])
							, "신청인원수": _util.nvl(obj["roundInfo"]["requestedMemberCnt"])
							, "배정완료수": _util.nvl(obj["roundInfo"]["assignedMemberCnt"])
							, "라운딩진행상태": _util.nvl(obj["roundInfo"]["procStatus"]) //진행중(P),확정(C),마감(D)					
							, "프로필": []								
						});
					}         
				}
				
				$(thisClass).trigger("evtFinishClubScheduleList");
				
        	}, function($err) {
				alert($err);
			});						
		}
		, getClubScheduleListData: function(){
			return this.clubScheduleList;
		}
		, getClubScheduleListPageData: function(){
			return this.clubScheduleListPageData;
		}
		, setClubScheduleListRequest: function(key, val){
			this.clubScheduleListRequest[key] = val;
		}
//------------------------ 라운드목록------------------------//			
//------------------------ 공지사항-----------------------------//
		, getClubNoticeList: function(){
			var thisClass = this;
			var club_seq = this.clubNoticeListRequest["동호회키"];
			var szClosedRoundDispYn = "N";
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CB001");
        	objJson.putPub("servicename", "getClubBoardList");   
        	objJson.putPub("listcount", 10);
        	objJson.putPub("currpageno", 1);
        	
			objJson.putParameter("clubSeq", club_seq);      
			objJson.putParameter("notice_yn", "Y");      
			
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		thisClass.clubNoticeList = [];
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					if(!items.length){
						items	= new Array(items);
					}
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						thisClass.clubNoticeList.push({
							"동호회키": _util.nvl(obj["club__seq"])
							, "게시판키": _util.nvl(obj["board__seq"])
							, "이미지": _util.nvl(obj["filepath"])
							, "제목": _util.nvl(obj["title"])
							, "댓글수": _util.nvl(obj["cr__cnt"])
							, "조회수": _util.nvl(obj["hit"])
							, "나이스샷": _util.nvl(obj["niceshot"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])			
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubNoticeList");
				
        	}, function($err) {
				alert($err);
			});			
		}
		, getClubNoticeListData: function(){
			return this.clubNoticeList;
		}
		, setClubNoticeListRequest: function(key, val){
			this.clubNoticeListRequest[key] = val;
		}
//------------------------ 공지사항-----------------------------//
	}
	
	//컨트롤파일
	function SelfClub(){				
		this.objComm = null;		
		this.club_seq = null;
		
		this.club_info = null;						
		this.objSelfClub_Info = null;
		this.objSelfClub_Round = null;
		this.objSelfClub_Notice = null;
	};
	
	SelfClub.prototype = {
	    onPageShow : function() {	    
	    	$("a").attr("href", "").attr("data-rel", "");
	    	this._init();	
	    }
	    , _beforeStart: function(){
	    	var 	thisClass = this;
	    	
	    	this._permitStart = {
				"동호회정보": false	
			}
			
	  		// 서버 메시지맵
			$.ajax({
				url: "../js/src/club/club_inc.js"
				, type: "get"
				, dataType: "script"
				, async: false
				, success: function(ret, sta){
					//alert("success!!");					
				}
				, error:function(e){
					//alert("error=" + e);
				}	
			});
			
			_cb.getClubInfoData({
				"콜백": function(ret, l){
					thisClass._permitStart["동호회정보"] = true;	
				}
			});
			
			_util.executeThread(function(){
				for(key in thisClass._permitStart){		
					if(!thisClass._permitStart[key]) return false;
				}
				return (true);
			}, function(){			
				thisClass._start();
			});
	    }
	    , _init: function(){	    	    	
	    		    	
	    	this.objComm = new clsComm_SelfClub();
	     	this.objSelfClub_Info = new clsSelfClub_Info();
	     	this.objSelfClub_Round = new clsSelfClub_Round();
			this.objSelfClub_Notice = new clsSelfClub_Notice();
			
			this.getParam();
			
	      this._beforeStart();
	      
	    	this._role();
	       
	      	this._bind();	 
	      	this._eventFinish();     	
	    }
	    , _start: function(){	    	
	    	//동호회기본정보
	    	this.club_info = _cb.getClubInfo();	    	
	    	this.objSelfClub_Info.setData(this.club_info.getInfoData());
	    	
	    	//동호회공지			
			this.objComm.setClubNoticeListRequest("동호회키", this.club_seq);
			this.objComm.getClubNoticeList();
			
			//라운드
			this.objComm.setClubScheduleListRequest("페이지",1);						
			this.objComm.setClubScheduleListRequest("동호회키", this.club_seq);
			this.objComm.getClubScheduleList();			
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	 	
	    	// 동호회공지 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubNoticeList", function(){
				var thisData = thisClass.objComm.getClubNoticeListData();
				thisClass.objSelfClub_Notice.setList(thisData);
			});
		
			//라운드 조회 완료 이벤트 
			$(this.objComm).bind("evtFinishClubScheduleList", function(){
				var thisData = thisClass.objComm.getClubScheduleListData()
				thisClass.objSelfClub_Round.setList(thisData);				
			});

	    }
		 , _bind: function(){
		 	var thisClass = this;
		 	
		 	//관리하기
		 	this.objSelfClub_Info.$getBtnAdmin().click(function(event){
		 		event.preventDefault();				
		 		if(!thisClass.club_info.isAdmin()){
		 			alert(thisClass.club_info.getError());
		 			return;
		 		}
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq		 		
		 		}
		 		$.mobile.changePage("club_control.html","slide",true);
		 	});
		 	
		 	//가입하기
		 	this.objSelfClub_Info.$getBtnJoin().click(function(event){
		 		event.preventDefault();		
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq
		 		}				
		 		$.mobile.changePage("club_join.html","slide",true);
		 	});
		 	
		 	//뒤로가기
		 	this.objSelfClub_Info.$getBtnClose().click(function(event){
		 		event.preventDefault();						
		 		_gf.CLUB_DATA = {}
		 		$.mobile.changePage("club.html","slide",true);
		 	});
		 	
		 	//라운드 상세보기
		 	this.objSelfClub_Round.$getLayer().on("click", "a", function(event){
		 		event.preventDefault();						
		 		var n = thisClass.objSelfClub_Round.$getLayer().find("a").index($(this));
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq
		 			, "라운드키": thisClass.objSelfClub_Round.listData[n]["라운드키"]
		 		}
		 		$.mobile.changePage("club_round_view.html","slide",true);
		 	});
		 	
		 	//공지사항 상세보기
		 	this.objSelfClub_Notice.$getLayer().on("click", "a", function(event){
		 		event.preventDefault();						
		 		var n = thisClass.objSelfClub_Notice.$getLayer().find("a").index($(this));
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq
		 			, "게시판키": thisClass.objSelfClub_Notice.listData[n]["게시판키"]
		 		}
		 		$.mobile.changePage("club_board_view.html","slide",true);
		 	});
		 	
		 	//메뉴
		 	$("section#self_club nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#self_club nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//이전
		 	$("section#self_club header div.top_title_B div.top_left a.btn10").click(function(event){
		 		event.preventDefault();
		 		_gf.CLUB_DATA = {
					"동호회키": thisClass.club_seq	
				}
		 		$.mobile.changePage("club.html","slide",true);	
		 	});
		}
		, getParam: function(){			
	   		this.club_seq = _gf.CLUB_DATA["동호회키"];
	   }
	   , _role: function(){
	    		
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}	